﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
 	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base id="href" href="<%=basePath%>">
<link rel="stylesheet" type="text/css" href="static/js/jquery-easyui-1.5.3/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="static/js/jquery-easyui-1.5.3/themes/icon.css"/>
<script type="text/javascript" src="static/js/jquery-easyui-1.5.3/jquery.min.js"></script>
<script type="text/javascript" src="static/js/jquery-easyui-1.5.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="static/js/jquery-easyui-1.5.3/locale/easyui-lang-zh_CN.js"></script>
<script language="javascript" type="text/javascript"src="static/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="static/js/consignhandle/checkBox.js"></script>
<script type="text/javascript"src="static/js/common/tooltip.js"></script>

<title>托单录入</title>
<style type="text/css">
	.validatebox-text{width:30px;}
	#volume{width:70px;}
	*[disabled]{background: #D3E0EC;color:#000;}
	select{border:none;border:1px solid #95B8E7;}
	input[type=text],select{border-radius:2px;}
</style>
</head>
<body>
<form id="form1" name="form1" method="post">
<div style="width: 100%;height: 100%;border: 0px;">
  	<div style="width:100%;text-align:center;">
    	  <tr>
    	     <td>
                                              业务类别
              <input id="tradeType" name="tradeType"/>				
            </td>
    	   
           <td style="width:12%;text-align:right;">
                    	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </td>
              <td>
             
        	托单编号<input type="text" name="tdh" id="tdh" maxlength="200"/>
            <a id="search">查询导入</a>
          
        	
            </td>
          </tr>
        </div>
<hr>
  <div id="searchImport" style="text-align:center;" >
    	托单编号:<input style="border: 1px solid rgb(149, 184, 231); width: 100px;" type="text" id="tradeCode" name="tradeCode" onpropertychange="search();" oninput="search();">
    	托运人自编号:<input style="border: 1px solid rgb(149, 184, 231); width: 100px;" type="text" id="selfCode" name="selfCode" onpropertychange="search();" oninput="search();">
    	提单号:<input style="border: 1px solid rgb(149, 184, 231); width: 100px;" type="text" id="bolCodeTxt" name="bolCodeTxt" onpropertychange="search();" oninput="search();">
		托运人<input style="border: 1px solid rgb(149, 184, 231); width: 100px;" type="text" name="tyr" id="tyr" maxlength="200" onpropertychange="search();" oninput="search();"/>
		卸货港<input style="border: 1px solid rgb(149, 184, 231); width: 100px;" type="text" name="xhg" id="xhg" maxlength="200" onpropertychange="search();" oninput="search();"/>
    	交货地<input style="border: 1px solid rgb(149, 184, 231); width: 100px;" type="text" name="jhd" id="jhd" maxlength="200" onpropertychange="search();" oninput="search();"/>
    	<table id="tradeList"></table>
    </div>
 <iframe id="iframeMain" name="iframeMain"                
                marginwidth="0" marginheight="0" frameborder="0" scrolling="no" width="100%" height="100%" onload="iframeReSize('iframeMain');" >
  </iframe>
</div>
 </form>
<script type="text/javascript">



function iframeReSize(iframename) {
	var pTar = document.getElementById(iframename);
	if (pTar) {
	//iframe高度自适应
	if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
	   pTar.height = pTar.contentDocument.body.offsetHeight;
	}else if (pTar.Document && pTar.Document.body.scrollHeight) {
	   pTar.height = pTar.Document.body.scrollHeight;
    }
	//iframe宽度自适应
	if (pTar.contentDocument && pTar.contentDocument.body.offsetWidth) {
	    pTar.width = pTar.contentDocument.body.offsetWidth;
	}else if (pTar.Document && pTar.Document.body.scrollWidth) {
	    pTar.width = pTar.Document.body.scrollWidth;
	}
   }
}

//业务类别
var flag = 0;
$("#tradeType").combobox({
	width:200,
	panelHeight:'auto',
	editable:false,
	valueField:'value',
	textField:'text',
	data:[{value:'-1',text:'--请选择业务类别--'},{value:'1',text:'出口'},{value:'2',text:'进口'},{value:'3',text:'沿江下水'},{value:'4',text:'沿江上水'},{value:'5',text:'沿海下水'},{value:'6',text:'沿海上水'},{value:'7',text:'其他'}],
	onLoadSuccess:function(){
    	$('#tradeType').combobox("setValue",'-1');
    },
    onChange:function(q){
    	
    	if("-1"==q|"1"==q|"7"==q){
    		$("#iframeMain").attr("src","consignMgr/consignWEBill?businessType="+q);    		
    		
    	}else if("2"==q){
    		
    		$("#iframeMain").attr("src", "consignMgr/consignWIBill?businessType="+q); 
    		
    	}else{    		
    		$("#iframeMain").attr("src", "consignMgr/consignNMBill?businessType="+q); 
    	}
    	//setTimeout(document.getElementById("iframeMain").contentWindow.document.getElementById("businessType").value =q, 1000);
      }
});
//查询导入
$("#search").linkbutton({
	iconCls:"icon-import",
	width:100
});
$('#searchImport').window({
	title:'导入托单',
    width:1000,
    height:410,
    minimizable:false,
    maximizable:false,
    resizable:false,
    closed:true,
    top:0,
    modal:true,
    iconCls:'icon-import'
});
$("#search").bind("click",function(){
	$('#searchImport').window("open");
	var keyword = $("#tdh").val();
	$("#tradeCode").val(keyword);
	$("#tradeList").datagrid("reload",{tradeCode:keyword,tradeType:$("#businessType").val()});
});

//托单列表
$("#tradeList").datagrid({
	width:1000,
	height:330,
	striped:true,
	singleSelect:true,
	pagination:true,
	loadMsg:'数据加载中,请稍后。。。',
	url:'consignMgr/getTradeListForImport.do',
	queryParams:{'tradeType':$("tradeType").val()},
	columns:[[
	    {field:'trade_code',title:'进仓编号',width:150,align:'center'},
	    {field:'agency_self_no',title:'托运人自编号',width:100,align:'center'},
		{field:'input_date',title:'录入时间',width:100,align:'center'},
		{field:'agency_man',title:'托运人',width:320},
		{field:'port_of_discharge',title:'卸货港',width:100},
		{field:'stop_harbour',title:'交货地',width:100}
	]],
	onDblClickRow:function(index,row){
		
		getConsignInfo(row.trade_code);
		$("#tdh").val(row.trade_code);
		$("#searchImport").window("close");
		
	}
});
function getConsignInfo(tradeCode)
{
	
	if(tradeCode.indexOf("WE")>-1)
	{
		
		    $('#tradeType').combobox('select',1);   
    		//$("#iframeMain").attr("src",'consignMgr/consignWEBill?businessType=1');    		
    		//document.getElementById("iframeMain").contentWindow.document.getElementById("businessType").value = "1";
    		setTimeout(document.getElementById('iframeMain').contentWindow.getConsignInfo(tradeCode), 1000)
    		
	
	}else if(tradeCode.indexOf("WI")>-1)
	{
		    $('#tradeType').combobox('select',2); 
    		$("#iframeMain").attr("src", 'consignMgr/consignWIBill?businessType=2'); 
    		//document.getElementById("iframeMain").contentWindow.document.getElementById("businessType").value = "2";
    		setTimeout(document.getElementById('iframeMain').contentWindow.getConsignInfo(tradeCode), 1000)
    
	}else if(tradeCode.indexOf("OT")>-1){
		    $('#tradeType').combobox('select',7); 
    		$("#iframeMain").attr("src",'consignMgr/consignWEBill?businessType=7');
    		//document.getElementById("iframeMain").contentWindow.document.getElementById("businessType").value = "7";
    		setTimeout(document.getElementById('iframeMain').contentWindow.getConsignInfo(tradeCode), 1000)
    	
	}else{
		    if(tradeCode.indexOf("JX")>-1)
		    {
		    	$('#tradeType').combobox('select',3); 
		    	//document.getElementById("iframeMain").contentWindow.document.getElementById("businessType").value = "3";
		    }else if(tradeCode.indexOf("JS")>-1)
		    {
		    	$('#tradeType').combobox('select',4);   
		    	//document.getElementById("iframeMain").contentWindow.document.getElementById("businessType").value = "4";
		    	}else if(tradeCode.indexOf("HX")>-1){
		    		$('#tradeType').combobox('select',5);   
		    		//document.getElementById("iframeMain").contentWindow.document.getElementById("businessType").value = "5";
		    	}else if(tradeCode.indexOf("HS")>-1){
		    		$('#tradeType').combobox('select',6); 
		    		//document.getElementById("iframeMain").contentWindow.document.getElementById("businessType").value = "6";
		    	}
		    $("#iframeMain").attr("src",'consignMgr/consignNMBill?businessType='+$('#tradeType').val());
		    setTimeout(document.getElementById('iframeMain').contentWindow.getConsignInfo(tradeCode), 1000)
	}
	
}

//动态搜索托单
function search(){
	var tradeCode = $("#tradeCode").val();
	var selfCode = $("#selfCode").val();
	var tyr = $("#tyr").val();
	var xhg = $("#xhg").val();
	var jhd = $("#jhd").val();
	$("#tradeList").datagrid("reload",{tradeCode:tradeCode,selfCode:encodeURI(selfCode),tyr:encodeURI(tyr),xhg:encodeURI(xhg),jhd:encodeURI(jhd),tradeType:$("#tradeType").val()});
}

</script>
</body>
</html>